Skip to content

Generate identifiers for unhydrated nodes #24665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
May 21, 2025

Conversation

CraigMacomber
Copy link
Contributor

Description

Allocate UUIDs instead of erroring for unhydrated nodes.

Reviewer Guidance

The review process is outlined on this wiki page.

@Copilot Copilot AI review requested due to automatic review settings May 20, 2025 19:37
@CraigMacomber CraigMacomber requested review from a team as code owners May 20, 2025 19:37
@github-actions github-actions bot added area: dds Issues related to distributed data structures area: dds: tree changeset-present base: main PRs targeted against main branch labels May 20, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates identifier handling for unhydrated TreeNodes by generating UUIDs on access instead of throwing errors, adjusts related tests, and updates documentation to reflect the new behavior.

  • Introduce a global identifier allocator to generate and store UUIDs for unhydrated nodes in objectNode.ts
  • Modify tests in treeNodeApi.spec.ts to assert new default-ID behavior both before and after hydration
  • Update schemaFactory docs to note identifier presence rules and add a changeset entry

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
packages/dds/tree/src/test/simple-tree/api/treeNodeApi.spec.ts Update tests to expect UUID allocation rather than errors for unhydrated nodes
packages/dds/tree/src/simple-tree/objectNode.ts Add globalIdentifierAllocator and logic to allocate & store default IDs
packages/dds/tree/src/simple-tree/api/schemaFactory.ts Revise doc comment to describe new identifier read/insertion rules
.changeset/public-snakes-fetch.md Add release notes for implicit identifier generation
Comments suppressed due to low confidence (1)

packages/dds/tree/src/test/simple-tree/api/treeNodeApi.spec.ts:1636

  • [nitpick] The test description uses the term 'unread' which is unclear; consider renaming to 'read identifier' for consistency with the first test.
it("hydrated object with defaulted unread identifier field", () => {

CraigMacomber and others added 2 commits May 20, 2025 15:16
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
---
TreeNodes now implicitly generate identifiers on access instead of throwing

Accessing a defaulted [identifier](https://fluidframework.com/docs/api/fluid-framework/schemafactory-class#identifier-property) on an [Unhydrated](https://fluidframework.com/docs/api/fluid-framework/unhydrated-typealias) `TreeNode` no longer throws a usage error.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: a quick code example would probably be helpful (I'm pushing for more of these generally, as I think they make a huge difference)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

@Josmithr Josmithr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few docs suggestions but otherwise looks good to me. Might still be good to get another set of eyes on this though, since it's a pretty big policy change.

Co-authored-by: Joshua Smithrud <54606601+Josmithr@users.noreply.github.com>
@noencke
Copy link
Contributor

noencke commented May 20, 2025

TreeNodeAPI.shortID and TreeIdentifierUtils.getShort() docs need to be updated, as they are now out of date.

@CraigMacomber
Copy link
Contributor Author

TreeNodeAPI.shortID and TreeIdentifierUtils.getShort() docs need to be updated, as they are now out of date.

TreeIdentifierUtils.getShort's docs are the same as TreeNodeAPI.shortID except that it does not document what happens in the case where the id is a user provided string.

What does it do in that case? Throw? Return undefined?

@noencke
Copy link
Contributor

noencke commented May 21, 2025

TreeNodeAPI.shortID and TreeIdentifierUtils.getShort() docs need to be updated, as they are now out of date.

TreeIdentifierUtils.getShort's docs are the same as TreeNodeAPI.shortID except that it does not document what happens in the case where the id is a user provided string.

What does it do in that case? Throw? Return undefined?

It returns undefined. FYI @daesunp.

@CraigMacomber
Copy link
Contributor Author

TreeNodeAPI.shortID and TreeIdentifierUtils.getShort() docs need to be updated, as they are now out of date.

TreeIdentifierUtils.getShort's docs are the same as TreeNodeAPI.shortID except that it does not document what happens in the case where the id is a user provided string.
What does it do in that case? Throw? Return undefined?

It returns undefined. FYI @daesunp.

I have updated their docs, and TreeStatus.New which was also out of date.

@CraigMacomber CraigMacomber enabled auto-merge (squash) May 21, 2025 22:34
@CraigMacomber CraigMacomber merged commit cd5976b into microsoft:main May 21, 2025
34 checks passed
@CraigMacomber CraigMacomber deleted the lazyId branch May 21, 2025 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: dds: tree area: dds Issues related to distributed data structures base: main PRs targeted against main branch changeset-present
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants